package com.bestcem.xm.user.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 订单时长枚举
 *
 * @author Linzhijian <zhijian.lin@idiaoyan.com>
 * @version v1.0
 * @date 2022/05/20514:14
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum OrderExtraDurationEnum {

    /**
     * 订单时长枚举
     */
    ORDER_EXTRA_DURATION_YEAR(0, "年","计算按年"),
    ORDER_EXTRA_DURATION_MONTH(1, "月","计算按月"),
    ORDER_EXTRA_DURATION_DAY(2, "天","计算按天");


    /**
     * 类型
     */
    private Integer type;

    /**
     * 单位
     */
    private String unit;

    /**
     * 状态描述
     */
    private String desc;


    /**
     * 通过type获取单位
     *
     * @param type
     * @return
     */
    public static String getByType(Integer type) {
        if (type != null) {
            for (OrderExtraDurationEnum value : values()) {
                if (value.getType().equals(type)) {
                    return value.getUnit();
                }
            }
        }
        return null;
    }

}
